package LeetCode.month04.day111;

/**
 * @author 16778
 * @date 2025/11/21 8:12
 * @description
 */
public class No1930 {
    public int countPalindromicSubsequence(String s) {
        int res = 0;
        for (char c = 'a';  c<='z' ; c++) {
            int start = s.indexOf(c);
            if(start == -1){
                continue;
            }
            int end = s.lastIndexOf(c);
            boolean[] visited = new boolean[26];
            for (int i = start; i<= end; i++) {
                int index = s.charAt(i)-'a';
                if(!visited[index]){
                    res++;
                    visited[index] = true;
                }
            }
        }
        return res;
    }
}
